#define _CRT_SECURE_NO_WARNINGS 1

#include<AT89X51.H>

unsigned char tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88}
unsigned char a = 0;

sbit clr = P3 ^ 7;

void delay(unsigned int t)
{
	unsigned int i, j;
	for (i = 0; i < t; i++)
	{
		for (j = 0; j < 200; j++);
	}
}

void display(unsigned char s)
{
	unsigned char t;
	for (t = 300; t > 0; t--)
	{
		P2 = 0x01; P1 = tab[s % 10]; delay(1);
		P2 = 0x02; P1 = tab[s / 10]; delay(1);
	}
}

void int0(void) interrupt 0 using 0
{
	delay(50);
	a++;
	if (a >= 60)
		a = 0;
}

void main()
{
	EA = 1;
	EX0 = 1;
	IT0 = 1;
	while (1)
	{
		display(a);
		if (clr == 0)
		{
			delay(50);
			if (clr == 0)
				a = 0;
		}

	}
}